//
//  BVConditionViewController.m
//  XiangYu
//
//  Created by YYKJ on 2017/6/19.
//  Copyright © 2017年 YYKJ. All rights reserved.
//  条件筛选

#import "BVConditionViewController.h"
#import "BVMineSingleAlertView.h"
#import "BVAddressAlertView.h"
#import "BVIndexSearchModel.h"

#define BUY_SEARCH_TABLEVIEWCELL1 @"UITableViewCell"
@interface BVConditionViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UITableView        *tabView;
@property (nonatomic ,strong) NSArray            *titleArr;
@property (nonatomic ,strong) BVIndexSearchModel *model;

@end

@implementation BVConditionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor BVBackgroundLightGrayColor]];
    
    [self layoutUI];
    
}

-(void)layoutUI{
    self.model = [[BVIndexSearchModel alloc]init];
    [self.view addSubview:self.tabView];
    
}
#pragma mark -
#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.titleArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BUY_SEARCH_TABLEVIEWCELL1];
        
        UILabel *lab = [[UILabel alloc]init];
        [cell.contentView addSubview:lab];
        [lab setFrame:CGRectMake(10, 0, 60, 45)];
        [lab setFont:[UIFont systemFontOfSize:14]];
        [lab setTag:100];
    }
    [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    UILabel *lab = (UILabel *)[cell.contentView viewWithTag:100];
    [lab setText:[NSString stringWithFormat:@"%@",self.titleArr[indexPath.row]]];
    
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    switch (indexPath.row) {
        case 0:{
            BVMineSingleAlertView *alert = [[BVMineSingleAlertView alloc]init:Sex];
            [alert showMKPAlertView];
            alert.AlertResult = ^(NSString *str) {
                self.model.sex = [str mutableCopy];
            };
        }
            break;
        case 1:{
            
            
        }
            break;
        case 2:{
            BVMineSingleAlertView *alert = [[BVMineSingleAlertView alloc]init:height];
            [alert showMKPAlertView];
            alert.AlertResult = ^(NSString *str) {
                self.model.height = [str mutableCopy];
            };
        }
            break;
        case 3:{
            BVMineSingleAlertView *alert = [[BVMineSingleAlertView alloc]init:Education];
            [alert showMKPAlertView];
            alert.AlertResult = ^(NSString *str) {
                self.model.education = [str mutableCopy];
            };
        }
            break;
        case 4:{
            BVAddressAlertView *alert = [[BVAddressAlertView alloc]init];
            [alert showMKPAlertView];
            alert.AlertResult = ^(NSString *str) {
                self.model.address = [str mutableCopy];
            };
            
        }
            break;
        case 5:{
            BVMineSingleAlertView *alert = [[BVMineSingleAlertView alloc]init:MonthlySalary];
            [alert showMKPAlertView];
            alert.AlertResult = ^(NSString *str) {
                self.model.income = [str mutableCopy];
            };
        }
            break;
            
        default:
            break;
    }
    
}

-(UITableView *)tabView{
    if (!_tabView) {
        self.tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH-64-49) style:UITableViewStylePlain];
        [self.tabView setDelegate:self];
        [self.tabView setDataSource:self];
        [self.tabView setBackgroundColor:[UIColor clearColor]];
        [self.tabView setTableFooterView:[UIView new]];
        [self.tabView setShowsVerticalScrollIndicator:NO];
        [self.tabView setRowHeight:45];
        [self.tabView setScrollEnabled:NO];
        [self.tabView registerClass:[UITableViewCell class] forCellReuseIdentifier:BUY_SEARCH_TABLEVIEWCELL1];
        
    }
    return _tabView;
}

-(NSArray *)titleArr{
    if (!_titleArr) {
        _titleArr = [NSArray arrayWithObjects:@"性别",@"年龄",@"身高",@"学历",@"所在地",@"收入",@"择偶标准",nil];
    }
    return _titleArr;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
